import uuid

def generate_id():
    """Generate unique ID for item"""
    return str(uuid.uuid4())[:8]

def create_item(items, name, item_type, level):
    """
    Add new item to collection

    Args:
        items (list): Current list of items
        name (str): Item name
        item_type (str): Item type/class
        level (int): Item level

    Returns:
        list: Updated list with new item
    """
    if len(items) >= 4:
        print("Error: Maximum 4 items!")
        return items

    new_item = {
        "id": generate_id(),
        "name": name,
        "type":item_type,
        "level":level}
    items.append(new_item)
    return items
        
def delete_item(items, item_id):
    """Remove item by ID"""
    for index, item in enumerate(items):
        if item["id"] == item_id:
            del items[index]
            print("Item deleted successfully!\n")
            return items
    print("Item not found!")
    return items
        
def display_item(items):
    """Display all items nicely"""
    if not items:
        print("No item in collection.\n")
        return
    print(f"Items:{len(items)}/4")
    for i ,items in enumerate(items,1):
        print(f"\n{i}.ID:{items["id"]}")
        print(f"  Name:{items["name"]}")
        print(f"  Type:{items["type"]}")
        print(f"  Level:{items["level"]}")
        
        
if __name__=="__main__":
    print("Testing create_item...")
    test_items = [ ]
    test_items = create_item(test_items, "Curry", "Shooter", 30)
    test_items = create_item(test_items, "Lebon Janse", "Wizard", 23)
    print(f"Total items: {len(test_items)}")
    for item in test_items:
        print(item)
    display_item(test_items)
    delete_item(test_items)
    display_item(test_items)